{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "d3fbf755",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "\n",
    "* 用户输入\n",
    "* 注释\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "051db76e",
   "metadata": {},
   "source": [
    "## 注释\n",
    "\n",
    "* 注释的意义 \n",
    "   * 1. 可以记录我们的代码过程意义（一般循环、条件判断、函数、对象、类都要有自己的描述，对变量作描述）\n",
    "   * 2. 可以忽略一部分代码，跳过该部分执行的代码"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "597d8b07",
   "metadata": {},
   "source": [
    "### 单行注释 ： # 被注释内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "971aef17",
   "metadata": {},
   "outputs": [],
   "source": [
    "# -*- coding:utf-8 -*-\n",
    "# Author:Zhichao"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f80d1f6c",
   "metadata": {},
   "source": [
    "### 多行注释 ： \"\"\" 被注释内容\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "5e3a4f16",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22\n",
      "bottles\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import random\n",
    "wait_time = random.randint(1,60)\n",
    "print(wait_time)\n",
    "\n",
    "word = \"bottles\"\n",
    "print(word)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9f230e50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "import random\n",
      "wait_time = random.randint(1,60)\n",
      "print(wait_time)\n",
      "\n",
      "word = \"bottles\"\n",
      "print(word)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# \"\"\" 被注释内容 \"\"\"  还可以打印变量 \n",
    "\n",
    "\n",
    "test1 ='''\n",
    "import random\n",
    "wait_time = random.randint(1,60)\n",
    "print(wait_time)\n",
    "\n",
    "word = \"bottles\"\n",
    "print(word)\n",
    "'''\n",
    "print(test1)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e4e45a0e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 或 在 python中存储其他语言的代码\n",
    "\n",
    "python_str_text = \"\"\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "276f3f8f",
   "metadata": {},
   "source": [
    "### 多行注释可以当做  str  赋值给变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "edcf4f8a",
   "metadata": {},
   "source": [
    "* str -- 分隔符，默认为所有的空字符，包括空格、换行(\\n)、制表符(\\t)等。\n",
    "* str() 函数将对象转化为适于人阅读的形式。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "911bb920",
   "metadata": {},
   "source": [
    "## 用户输入"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "324b5508",
   "metadata": {},
   "source": [
    "* while True + count 计数器  VS  for循环 + range()\\   \n",
    "   \n",
    "   while True + 结束条件\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "16e885f4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙,缠缠绵绵到天涯... 5\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 10\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 15\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 20\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 25\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 30\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 35\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 40\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 45\n",
      "你是风儿我是沙,缠缠绵绵到天涯... 50\n"
     ]
    }
   ],
   "source": [
    "# while True + count 计数器  VS  for循环 + range()\\\n",
    "# while True + 结束条件\n",
    "\n",
    "\n",
    "count = 0\n",
    "while True:\n",
    "    # count = count+1\n",
    "    count +=5\n",
    "    print(\"你是风儿我是沙,缠缠绵绵到天涯...\",count)\n",
    "    if count == 50:\n",
    "        break\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "92d96825",
   "metadata": {},
   "source": [
    "* 用户输入的数据 VS 数据库的数据\n",
    "* 优化 ： \n",
    "   * 1. 输入不正确时继续输入。 \n",
    "   * 2.  设置输入失败的次数"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7e24cb7a",
   "metadata": {},
   "source": [
    "* 简单的数据结构有 ： 数值和字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "0b32e5b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:name\n",
      "age:15\n",
      "job:123\n",
      "salary:66235\n",
      "----- INFO OF name------\n",
      "age:15\n",
      "job:123\n",
      "salary:66235\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''----- INFO OF ''' + name +'''------''' + '''\n",
    "age:''' + age+'''\n",
    "job:''' + job +'''\n",
    "salary:'''+salary\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "* 登录系统：模拟数据库数据 复杂的数据结构："
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "36ae85c1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的账号：Twings\n",
      "请输入您的密码：666\n",
      "欢迎我们尊贵的会员登录系统使用~\n",
      "尊贵的会员，您还有 9 次查询机会\n",
      "尊贵的会员，您还有 8 次查询机会\n",
      "尊贵的会员，您还有 7 次查询机会\n",
      "尊贵的会员，您还有 6 次查询机会\n",
      "尊贵的会员，您还有 5 次查询机会\n",
      "尊贵的会员，您还有 4 次查询机会\n",
      "尊贵的会员，您还有 3 次查询机会\n",
      "尊贵的会员，您还有 2 次查询机会\n",
      "尊贵的会员，您还有 1 次查询机会\n",
      "尊贵的会员，您还有 0 次查询机会\n",
      "尊贵的会员，今日次数已经没了哦~请明天再来吧~\n"
     ]
    }
   ],
   "source": [
    "user_data_vip = [\"Twings\"]                         \n",
    "user_data = ['Wulayt']                        \n",
    "password_data = \"999\"                               \n",
    "password_data_vip = \"666\"\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1\n",
    "    \n",
    "    username = input(\"请输入您的账号：\")\n",
    "    password = input(\"请输入您的密码：\")\n",
    "    if username in user_data_vip:\n",
    "            if password == password_data_vip:\n",
    "          \n",
    "             print(\"欢迎我们尊贵的会员登录系统使用~\" )\n",
    "             count = 10\n",
    "             while True:\n",
    "                if count == 0:\n",
    "                    print(\"尊贵的会员，今日次数已经没了哦~请明天再来吧~\")\n",
    "                    break\n",
    "                else:\n",
    "                    count -= 1\n",
    "                    print(\"尊贵的会员，您还有\", count, \"次查询机会\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}